package com.woniu.outlet.dao;

import com.woniu.outlet.po.ProcessHandover;
import com.woniu.outlet.po.ProcessHandoverExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface ProcessHandoverMapper {
    long countByExample(ProcessHandoverExample example);

    int deleteByExample(ProcessHandoverExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(ProcessHandover record);

    int insertSelective(ProcessHandover record);

    List<ProcessHandover> selectByExample(ProcessHandoverExample example);

    ProcessHandover selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") ProcessHandover record, @Param("example") ProcessHandoverExample example);

    int updateByExample(@Param("record") ProcessHandover record, @Param("example") ProcessHandoverExample example);

    int updateByPrimaryKeySelective(ProcessHandover record);

    int updateByPrimaryKey(ProcessHandover record);

    @Select("<script>" +
            "select ph.id id,ph.order_code orderCode,ph.process_code processCode,ph.process_name processName,handover_person_id handoverPersonId,ph.behandover_person_id behandoverPersonId,ph.handover_time handoverTime,ph.good_num goodNum,ph.cost_num costNum,ph.waste_num wasteNum,ph.planned_num plannedNum,ph.spare1 spare1,w1.username handoverName,w2.username beHandoverName\n" +
            "from ERP_process_handover ph,erp_system_management.ERP_worker w1,erp_system_management.ERP_worker w2 \n" +
            "where ph.handover_person_id = w1.id and ph.behandover_person_id = w2.id and ph.spare1=\"未报工\"\n" +
            "<if test='orderCode !=null and orderCode != \"\"'>and ph.order_code like '%${orderCode}%'</if>" +
            "</script>")
    List<ProcessHandover> selectAll (String orderCode);

    @Select("<script>" +
            "select ph.id id,ph.order_code orderCode,ph.process_code processCode,ph.process_name processName,handover_person_id handoverPersonId,ph.behandover_person_id behandoverPersonId,ph.handover_time handoverTime,ph.good_num goodNum,ph.cost_num costNum,ph.waste_num wasteNum,ph.planned_num plannedNum,ph.spare1 ,w1.username handoverName,w2.username beHandoverName\n" +
            "from ERP_process_handover ph,erp_system_management.ERP_worker w1,erp_system_management.ERP_worker w2 \n" +
            "where ph.handover_person_id = w1.id and ph.behandover_person_id = w2.id and ph.spare1=\"已报工\" \n" +
            "<if test='orderCode !=null and orderCode != \"\"'>and ph.order_code like '%${orderCode}%'</if>" +
            "</script>")
    List<ProcessHandover> selectWorkReport (String orderCode);

    void insertBy(ProcessHandover record);
}